<?php
namespace Main\Controller;
use Think\Controller;
class LoginController extends Controller {

    function __construct()
    {
        parent::__construct();
    }


    public function index(){
        $mid = session('mid');
        if($mid){
            die($this->success('您已经登录过了！',U('index/index')));
        }
        if(IS_POST){
            $user_name = I('user_name');
            $password = I('password');
            if($user_name != 'weiyuekj' || $password != 'weiyuekj2016')
                die($this->error('登录失败，帐号不存在或者密码不正确！'));
            session('mid','weiyuekj');
            die($this->success('登录成功！',U('index/index')));
        }
        $this->assign('title','登录');
        $this->display();
    }

    public function out(){
        session('mid',null);
        $this->error('退出成功！',U('login/index'));
    }


    /* 生成验证码 */
    public function verify()
    {
        $Verify = new \Think\Verify();
        $Verify->entry();
    }
    public function check_verify($code, $id = ''){
        $verify = new \Think\Verify();
        $res = $verify->check($code, $id);
        if(!$res){
            die($this->error('验证码错误'));
        }
    }



}